﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using System.Xml;
namespace Tracy.CoreLib.Data
{
    public partial class RssModel : XmlModel_AutoParseFunctions
    {
        public class RssChannel : XmlModelContainer_CommonFunctions, IXmlModelContainer
        {
            #region 构造函数
            public RssChannel(XmlNode node) : base(node) { }
            public RssChannel(string xml) : base(xml) { }
            public RssChannel() : base() { }
            #endregion

            public string XmlNodeName
            {
                get
                {
                    return Constants.CONST_TAG_CHANNEL;
                }
            }

            public string Title
            {
                get { return Data[Constants.CONST_TAG_TITLE]; }
            }

            public string Description
            {
                get
                {
                    if (Data.ContainsKey(Constants.CONST_TAG_DESCRIPTION)) return Data[Constants.CONST_TAG_DESCRIPTION];
                    else return "";
                }
            }

            public IXmlModelItem GenerateChild(XmlNode node)
            {
                return new RssModel.RssItem(node);
            }

            protected override void PreParseXml(XmlNode node)
            {
                //if (node.Name != XmlNodeName)
                //{
                //    node = SelectNode(node, XmlNodeName, true);
                //}

                Data[Constants.CONST_TAG_TITLE] = SelectNode(node, Constants.CONST_TAG_TITLE, true).InnerText;
                //description = SelectNode(node, Constants.CONST_TAG_DESCRIPTION, true).InnerText;
                //XmlNodeList itemlist = SelectNodes(node, Constants.CONST_TAG_ITEM);
                //foreach (XmlNode itemNode in itemlist){
                //    AddItem(itemNode);
                //}
            }

            //protected override void GenerateCustomizedXml(XmlDocument doc, XmlNode newNode)
            //{
            //    //AppendTextChildNode(doc, newNode, Constants.CONST_TAG_DESCRIPTION, Description);
            //   // AppendTextChildNode(doc, newNode, Constants.CONST_TAG_TITLE, Title);
            //}
        }

    }
}